<?php
/**
* Display the category edition screen
*
* @author       Fabrice Douteaud <clearbudget@douteaud.com>
* @package      snippets
* @access       public
*/

/***********************************************************************

  Copyright (C) 2008  Fabrice douteaud (clearbudget@douteaud.com)

    This file is part of ClearBudget.

    ClearBudget is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ClearBudget is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ClearBudget.  If not, see <http://www.gnu.org/licenses/>.


************************************************************************/
//prevent direct access
if(!defined('ENGINEON')) die('Direct access forbidden');

function makeKeywordTableRow($id=null, $keyword=null, $keywordCategory=null, $categories=null, $keys) {
  class_debug::addMsg(__FILE__, 'building keywords table', DEBUGINFO);
  $str = '<tr>';
  $str .= '<td>';//<input type="text" size="3" disabled value="'.$id.'" style="text-align:right"> - ';
  $str .= '<input type="text" value="'.$keyword.'" id="'.$id.'_keyword"></td>';
  $str .= '<td>';
  $str .= '<select id="'.$id.'_category" name="categorySelector">';
  foreach($categories as $category) {
    $str .= '<option value="'.$category['id'].'"';
    if($category['id'] == $keywordCategory) $str .= ' selected';
    $str .= '>'.$category['name'].'</option>';
    }
  $str .= '</select></td>';
  $str .= '<td width="30"><img class="hidden" id="keywordLoading-'.$id.'" src="style/icons/icon_Loading.gif"></td>';
  $str .= '<td><a href="#" editKeyword="true" id="'.$id.'">'.$keys->link_save.'</a></td>';
  $str .= '</tr>';
  return $str;
  }
  
?>
<!--<div class="title"><?php echo $keys->pageTitle_editKeywords; ?></div><br/>-->
<div class="tableDiv">
<table class="tableReport" onMouseOver="javascript:trackTableHighlight(event, '#E6EAE9');" onMouseOut="javascript:highlightTableRow(0);">
  <caption><?php echo $keys->text_keywordSettingsSetup; ?></caption>
  <tr>
    <th><?php echo $keys->text_keyword; ?></th>
    <th><?php echo $keys->text_categoryNameLong; ?></th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>
<?php
$count = 0;
$additionnalRows = 5;
foreach($keywords as $keyword) {
  $count++;
  echo makeKeywordTableRow($keyword['id'], $keyword['keyword'], $keyword['category'], $categories, $keys);
  }
if($count == 0) $additionnalRows = 10;
$maxCount = $count + $additionnalRows;
while($count<$maxCount) {
  $count++;
  echo makeKeywordTableRow('-'.$count, '', '', $categories, $keys);
  }
?>
</table>
</div>
<br/>
